import React, { Component } from 'react'
import {connect} from 'react-redux'
class Summary extends Component {
  render () {
    const {sum} = this.props
    return (
      <p>total: {sum}</p>
    )
  }
}
function mapStateToProps (state, ownProps) {
  let sum = 0
  for (let x in state) {
    if (state.hasOwnProperty(x)) {
      sum = sum + state[x]
    }
  }
  return {
    sum 
  }
}
function mapDispatchToProps (dispatch, ownProps) {
  return {}
}
export default connect(mapStateToProps, mapDispatchToProps)(Summary)